set(LITEAPP_PREBUILT_DIRECTORY "D:/workspace/esp32_vscode/LiteApp/prebuilt")
# set(LITEAPP_PREBUILT_DIRECTORY "D:/workspace/esp/esp-lite-app/prebuilt")

list(APPEND TARGET_SOURCE_DIRECTORY_LIST ${CMAKE_CURRENT_SOURCE_DIR})
list(APPEND TARGET_SOURCE_DIRECTORY_LIST ${CMAKE_CURRENT_SOURCE_DIR}/ESP32S3ConsoleApplication)

list(APPEND TARGET_INCLUDE_DIRECTORY_LIST ${CMAKE_CURRENT_SOURCE_DIR})
list(APPEND TARGET_INCLUDE_DIRECTORY_LIST ${CMAKE_CURRENT_SOURCE_DIR}/ESP32S3ConsoleApplication)

list(APPEND TARGET_INCLUDE_DIRECTORY_LIST ${LITEAPP_PREBUILT_DIRECTORY}/include/LiteApp/Interface)
list(APPEND TARGET_INCLUDE_DIRECTORY_LIST ${LITEAPP_PREBUILT_DIRECTORY}/include/LiteApp/Application)
list(APPEND TARGET_INCLUDE_DIRECTORY_LIST ${LITEAPP_PREBUILT_DIRECTORY}/include/LiteApp/GUI)
list(APPEND TARGET_INCLUDE_DIRECTORY_LIST ${LITEAPP_PREBUILT_DIRECTORY}/include/LiteApp/Utility)
list(APPEND TARGET_INCLUDE_DIRECTORY_LIST ${LITEAPP_PREBUILT_DIRECTORY}/include/LiteApp/LuaScript)
list(APPEND TARGET_INCLUDE_DIRECTORY_LIST ${LITEAPP_PREBUILT_DIRECTORY}/include/Lua)
list(APPEND TARGET_INCLUDE_DIRECTORY_LIST ${LITEAPP_PREBUILT_DIRECTORY}/include/LuaBridge3/include)

list(APPEND TARGET_DEFINITIONS_LIST PLATFORM_ESP)

# register component
idf_component_register(SRC_DIRS ${TARGET_SOURCE_DIRECTORY_LIST} INCLUDE_DIRS ${TARGET_INCLUDE_DIRECTORY_LIST})

# prebuilt library
add_prebuilt_library(prebuilt_liteapp ${LITEAPP_PREBUILT_DIRECTORY}/lib/libLiteApp.a REQUIRES "esp_common" "nvs_flash" "spiffs" "esp_eth" "esp_netif" "esp_wifi" "esp_http_server" "esp_lcd" "bt")
add_prebuilt_library(prebuilt_lua ${LITEAPP_PREBUILT_DIRECTORY}/lib/libLua.a REQUIRES "newlib")
add_prebuilt_library(prebuilt_protocol_examples_common ${LITEAPP_PREBUILT_DIRECTORY}/lib/libprotocol_examples_common.a REQUIRES "esp_wifi" "esp_eth" "driver" "esp_netif")
list(APPEND TARGET_LIBRARY_LIST prebuilt_liteapp)
list(APPEND TARGET_LIBRARY_LIST prebuilt_lua)
list(APPEND TARGET_LIBRARY_LIST prebuilt_protocol_examples_common)

# compile definitions
target_compile_definitions(${COMPONENT_LIB} PUBLIC ${TARGET_DEFINITIONS_LIST})
target_compile_options(${COMPONENT_LIB} PUBLIC -Wno-unused-variable -Wno-error=unused-but-set-parameter)
target_link_libraries(${COMPONENT_LIB} PUBLIC ${TARGET_LIBRARY_LIST})
